#include<bits/stdc++.h>
using namespace std;
const int N=81;
int n,m;
struct node{int c,t,w;}a[N];
inline bool cmp(node x,node y){return 1ll*x.w*y.t>1ll*y.w*x.t;}
long long f[3005],sum,ans;
int mid,d[N];
void dfs(int x,int res,long long w){
	if(x==mid+1) return ans=max(ans,w+f[min(res,3000)]),void();
	for(int i=max(0,d[x]-9);i*a[x].t<=res&&i<=a[x].c;++i) dfs(x+1,res-i*a[x].t,w+1ll*a[x].w*i);
}
int main(){
	freopen("book.in","r",stdin);
	freopen("book.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;++i) cin>>a[i].c;
	for(int i=1;i<=n;++i) cin>>a[i].t;
	for(int i=1;i<=n;++i) cin>>a[i].w;
	sort(a+1,a+n+1,cmp);
	cin>>m;
	int mm=m;
	long long sum=0;
	for(int i=1;i<=n;++i){
		if(a[i].c>m/a[i].t){
			sum+=1ll*m/a[i].t*a[i].w;
			d[i]=m/a[i].t;
			m%=a[i].t;
			mid=i;
			break;
		}else m-=a[i].c*a[i].t,sum+=1ll*a[i].c*a[i].w,d[i]=a[i].c;
	}
	if(!mid){
		printf("%lld\n",sum);
		return 0;
	}
	for(int i=n;i>mid;--i)
	for(int j=3000;j>=a[i].t;--j)
	for(int k=1;k*a[i].t<=j&&k<=a[i].c;++k)
		f[j]=max(f[j],f[j-k*a[i].t]+1ll*k*a[i].w);
	for(int i=1;i<=3000;++i) f[i]=max(f[i-1],f[i]);
	sum=0;
	for(int i=1;i<=mid-8;++i) sum+=1ll*a[i].w*d[i],mm-=d[i]*a[i].t;
	dfs(max(1,mid-7),mm,sum);
	printf("%lld\n",ans);
	return 0;
}

